package com.weiyuwqj.controller.user;

import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.model.BusItemCollect;
import com.weiyuwqj.api.model.BusItemInvest;
import com.weiyuwqj.api.service.BusInvestCollectService;
import com.weiyuwqj.api.service.BusInvestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/6.
 * 债权转让列表
 */
@Controller
public class UserDebtController {

    @Autowired
    private BusInvestService investService;
    @Autowired
    private BusInvestCollectService investCollectService;

    /**
     * 个人中心债权转让列表
     * @param p
     * @param debtStatus
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/user/debt/list",method = RequestMethod.POST)
    public Object list(Paginator p,Integer debtStatus,HttpServletRequest request){
        Integer userId = (Integer) request.getSession().getAttribute("userId");
        Map map=new HashMap();
        map.put("debtStatus",debtStatus);
        map.put("userId",userId);
        return null;//investService.getUserDebtList(p, map);
    }

    /**
     * 个人中心发布债权详情
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/user/debt/detail",method = RequestMethod.POST)
    public Object detail(Integer id){
/*        //根据investId统计已获取的收益
        BigDecimal repayAmount = investCollectService.sumRepayCollectByInvestId(id);
        //根据investId统计未获取的收益
        BigDecimal notRepayAmount = investCollectService.sumNotRepayCollectByInvestId(id);
        //下次回款时间
        BusItemCollect itemCollect = investCollectService.getNextCollectByInvestIdAndTime(id);
        Map map = new HashMap();
        map.put("repayAmount",repayAmount);
        map.put("notRepayAmount",notRepayAmount);
        map.put("collectTime",itemCollect.getCollectTime());*/
        return null;
    }


}
